/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package phd.dupenois.es.nplusn;

import java.util.HashMap;
import java.util.Set;

/**
 *
 * @author mpd209
 */
public class SolutionClass {
    private HashMap<String, Objective> objectives;
    private HashMap<String, Baseline> baselines;
    public SolutionClass(){
        objectives = new HashMap<String, Objective>();
        baselines = new HashMap<String, Baseline>();
    }

    public <T extends Number> void addObjective(String name, boolean miminise){
        addObjective(name, new Objective<T>(name, miminise));
    }
    public void addObjective(String name, Objective objective){
        objectives.put(name, objective);
    }
    public Set<String> getObjectiveNames(){
        return objectives.keySet();
    }
    public Objective getObjective(String name){
        return objectives.get(name);
    }

    public boolean objectiveExists(String name){
        return objectives.containsKey(name);
    }


    public <T extends Number> void addBaseline(String name, String objectiveName, T value){
        if(!objectiveExists(objectiveName)){
            throw new IllegalArgumentException("Objective "+objectiveName+" not found");
        }
        Objective obj = getObjective(objectiveName);
        if(!obj.isValueValid(value)){
            throw new IllegalArgumentException("Value "+value+" is of an invalid type");
        }
        addBaseline(name, obj, value);
    }
    public <T extends Number> void addBaseline(String name, Objective<T> objective, T value){
        if(!objective.isValueValid(value)){
            throw new IllegalArgumentException("Value "+value+" is of an invalid type");
        }
        addBaseline(name, new Baseline(objective, value));
    }
    public void addBaseline(String name, Baseline baseline){
        baselines.put(name, baseline);
    }
    public Set<String> getBaselineNames(){
        return baselines.keySet();
    }
    public Baseline getBaseline(String name){
        return baselines.get(name);
    }

    public boolean baselineExists(String name){
        return baselines.containsKey(name);
    }

}
